package com.intelligentmeterreadingsys.waterlist.copywater.activity;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import android.annotation.SuppressLint;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.intelligentmeterreadingsys.R;

public class CopyWaterlistAdapter extends BaseAdapter {
    @SuppressLint("UseSparseArrays")
    private static Map<Integer, View> m = new HashMap<Integer, View>();

    private List<String> items;
    private LayoutInflater inflater;

    public CopyWaterlistAdapter(List<String> items, Context context) {
	super();
	this.items = items;
	this.inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    }

    @Override
    public int getCount() {

	return items.size();
    }

    @Override
    public Object getItem(int position) {

	return items.get(position);
    }

    @Override
    public long getItemId(int position) {

	return position;
    }

    @Override
    public View getView(int position, View contentView, ViewGroup parent) {

	contentView = m.get(position);
	if (contentView == null) {
	    contentView = inflater.inflate(R.layout.waterlist_listview, null);
	    TextView text = (TextView) contentView.findViewById(R.id.copywaterlist_itme);
	    text.setGravity(2);
	    text.setTextSize(20);
	    text.setText(items.get(position));

	}
	m.put(position, contentView);
	return contentView;

    }
}
